package com.ruoyi.business.enums;

import java.util.Arrays;
import java.util.Optional;

public enum VipEnum {
    NO_VIP(0,"否") ,
    VIP(1,"是") ;
    private Integer code ;
    private String desc ;

    VipEnum(int code, String desc){
        this.code = code ;
        this.desc = desc ;
    }

    public static boolean checkExist(int code){

        Optional<VipEnum> dealOp = Arrays.stream(VipEnum.values()).filter(deal -> deal.code == code).findFirst() ;
        return dealOp.isPresent() ;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(Integer code){
        Optional<VipEnum> dealOp = Arrays.stream(VipEnum.values()).filter(deal -> deal.code == code.intValue()).findFirst() ;
        return dealOp.get().desc ;
    }
}
